package com.orchidea.uml.manager.command
{
    import com.orchidea.uml.model.document.Document;
import com.orchidea.uml.model.document.DocumentNode;
import com.orchidea.uml.model.document.Entity;

    public class AddEntityCommand implements IUndoable
    {

        private var _timestamp : Date;

        private var document : Document;
        private var entity : Entity;

        public function get timestamp( ) : Date { return _timestamp; }
		public function get description( ) : String { return "Add entity"; }


        public function AddEntityCommand(document:Document, entity:Entity)
        {
            this.document = document;
            this.entity = entity;
        }

        public function execute():void
        {
            if ( _timestamp == null )
            {
				// don't overwrite the timestamp on redo
				_timestamp = new Date();
			}

            var node:DocumentNode = new DocumentNode(entity);

            document.add(node);
        }

        public function undo():void
        {
        }

        public function redo():void
        {
            execute();
        }
    }
}